package entities_testCase;

import junit.framework.TestCase;
import entities.AcdcProgram;
import entities.Course;

public class AcdcProgramTest extends TestCase {
	Course crs1;
	Course crs2;
	Course crs3;
	Course crs4;
	String[] prgm1 = { "BSCCS1" };
	String[] prgm2 = { "BSCCS1", "BSCCM2" };
	String[] prgm3 = { "BSCCM1" };
	String[] prgm4 = {};

	public void setUp() {
		new AcdcProgram("BSCCS1");
		new AcdcProgram("BSCCM1");
		new AcdcProgram("BSCCM2");
		crs1 = new Course("CS2115", prgm1);
		crs2 = new Course("CS3342", prgm2);
		crs3 = new Course("SM2222", prgm3);
		crs4 = new Course("MA2172", prgm4);
	}

	public void tearDown() {
		Course.clear();
		AcdcProgram.clear();
	}

	public void test_insertTwice() {
		new AcdcProgram("BSCCS1");
		assertEquals(3, AcdcProgram.getAllPrograms().length);
	}

	public void test_basicGetterAndSetter() {
		String[] prgm = AcdcProgram.getAllPrograms();
		assertEquals(3, prgm.length);
		AcdcProgram prgm1 = AcdcProgram.getProgramByCode("BSCCS1");
		assertEquals(2, prgm1.getCourse().length);
		assertEquals("BSCCS1", prgm1.getCode());
		AcdcProgram prgm2 = AcdcProgram.getProgramByCode("BSCCM1");
		assertEquals(1, prgm2.getCourse().length);
		assertEquals("SM2222", prgm2.getCourse()[0]);
	}

	// for loop coverage
	public void test_emptyAndOnlyOneElement() {
		AcdcProgram.clear();
		assertEquals(0, AcdcProgram.getAllPrograms().length);
		new AcdcProgram("BSCCS1");
		assertEquals(1, AcdcProgram.getAllPrograms().length);
	}

	// for loop coverage
	public void test_emptyAndOnlyOneCourse() {
		AcdcProgram noCourse = new AcdcProgram("noCourse");
		assertEquals(0, noCourse.getCourse().length);
	}
}
